package cn.wsalix.observable.service.impl;

import java.util.Observable;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.wsalix.admin.entity.SysUser;
import cn.wsalix.admin.form.UserForm;
import cn.wsalix.admin.service.UserService;
import cn.wsalix.observable.service.RegisterService;
import cn.wsalix.user.service.UserCenterService;
import cn.wsalix.user.service.UserInfoService;

@Service("registerService")
public class RegisterServiceImpl extends Observable implements
		RegisterService {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	private SysUser user;
	@Autowired
	private UserService userService;
	@Autowired
	private UserInfoService userInfoService;
	@Autowired
	private UserCenterService userCenterService;

	@PostConstruct  
	public void init() {  
		logger.info("==========init");  
		addObserver(userCenterService);
		addObserver(userInfoService);
		addObserver(userService);
	}  

	@Transactional
	@Override
	public void register(UserForm userForm) {		
		setChanged();
		notifyObservers(userForm);
	}

	@PreDestroy  
	public void destroy() {  
	    logger.info("==========destroy");  
	}
	public SysUser getUser() {
		return user;
	}
	public void setUser(SysUser user) {
		this.user = user;
	}
	
}
